/*!
 * \file build_sym_table_visitor_test.cc
 *
 * \brief BuildSymTableVisitor tests
 *
 * \date Started: 6/8/2010
 * \date Last Modified: 6/8/2010
 * \authors Alan LaMielle
 *
 * Copyright (c) 2010, Colorado State University <br>
 * All rights reserved. <br>
 * See ../../COPYING for details. <br>
 */

#include <iegenlib/iegenlib.h>

#include <gtest/gtest.h>

using iegenlib::TUPLE;
using iegenlib::EXISTENTIAL;
using iegenlib::SYMBOLIC;
using iegenlib::UFCALL;

using iegenlib::SymType;
using iegenlib::IEGenLibContext;
using iegenlib::Set;
using iegenlib::Relation;
using iegenlib::Symbolic;
using iegenlib::PresSet;
using iegenlib::PresRelation;
using iegenlib::BuildSymTableVisitor;
using iegenlib::StringException;

//All tests in BuildSymTableVisitorTest compare the expression vectors size
//after we have created it in the symboltable visitor

#if 0
TEST(BuildSymTableVisitorTest, emptyTestsSet) {

   std::string temp="{[]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  :\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);

   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, emptyTestsSet) {

   std::string temp="{[]}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(0,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, VarTupTestsSet) {

   std::string temp="{[x,y]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, VarTupTestsSet) {

   std::string temp="{[x,y]}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, lotsVarTupTestsSet) {

   std::string temp="{[u,v,w,x,y,z]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, lotsVarTupTestsSet) {

   std::string temp="{[u,v,w,x,y,z]}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(6,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, varTupTestsWithconstraintsSet) {

   std::string temp="{[x,y]:x<y}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, varTupTestsWithconstraintsSet) {

   std::string temp="{[x,y]:x<y}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, symConstPassedinTestsSet) {

   std::string temp="{[x,y]:x<S}";
   std::string after="SYMCONSTS  : 0\nTUPLEVARS  : 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   l1.push_back("S");
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();
   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, symConstPassedinTestsSet) {

   std::string temp="{[x,y]:x<S}";
   IEGenLibContext context;
   context.addSymbolic(Symbolic("S"));
   Set PS(temp, context);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(1,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, symConstNotPassedinTestsSet) {

   std::string temp="{[x,y]:x<S}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0\nEXISTENTIAL: 0\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, symConstNotPassedinTestsSet) {

   std::string temp="{[x,y]:x<S}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
   //The set {[x,y]:x<S} has 0 totals[SYMBOLIC] and
   // 0 totals[EXISTENTIAL] because the existential variable
   // S was eliminated by the ISL code in the islSimplify() method   
}

#if 0
TEST(BuildSymTableVisitorTest, functionTestsNoSymconstPassedSet) {

   std::string temp="{[x,y]:x<f(S)}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0\nEXISTENTIAL: 0\n";
   after+= "UFCALLS    : 0\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, functionTestsNoSymconstPassedSet) {

   std::string temp="{[x,y]:x<f(S)}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(1,totals[EXISTENTIAL]);
   EXPECT_EQ(1,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, functionTestsSymconstPassedSet) {

   std::string temp="{[x,y]:x<f(S)}";
   std::string after="SYMCONSTS  : 0\nTUPLEVARS  : 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    : 0\nCONST      : 0";
   PresSet *PS = pres_parser::parse_set(temp);
   list<string> l1;
   l1.push_back("S");
   BuildSymTableVisitor stv(l1);
   PS->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, functionTestsSymconstPassedSet) {

   std::string temp ="{[x,y]:x<f(S)}";
   IEGenLibContext context;
   context.addSymbolic(Symbolic("S"));
   Set PS(temp, context);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(1,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(1,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, emptyTestsRel) {

   std::string temp="{[]->[]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  :\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();
   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, emptyTestsRel) {

   std::string temp ="{[]->[]}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(0,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, varToNoVarRel) {

   std::string temp="{[x,y]->[]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, varToNoVarRel) {

   std::string temp ="{[x,y]->[]}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(2,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, VarTupTestsRel) {

   std::string temp="{[x,y]->[x,y]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, VarTupTestsRel) {

   std::string temp ="{[x,y]->[x,y]}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(4,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, lotsVarTupTestsRel) {

   std::string temp="{[u,v,w,x,y,z]->[u,v,w,x,y,z]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0 0 0 0 0 0 0 0 0\n";
   after+= "EXISTENTIAL:\nUFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, lotsVarTupTestsRel) {

   std::string temp ="{[u,v,w,x,y,z]->[u,v,w,x,y,z]}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(12,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, varTupTestsWithconstraintsRel) {

   std::string temp="{[x,y]->[x,z]:x<y}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, varTupTestsWithconstraintsRel) {

   std::string temp ="{[x,y]->[x,z]:x<y}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(4,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, symConstPassedinTestsRel) {

   std::string temp="{[x,y]->[x,y,z]:x<S}";
   std::string after="SYMCONSTS  : 0\nTUPLEVARS  : 0 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   l1.push_back("S");
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();
   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, symConstPassedinTestsRel) {

   std::string temp ="{[x,y]->[x,y,z]:x<S}";
   IEGenLibContext context;
   context.addSymbolic(Symbolic("S"));
   Relation PR(temp, context);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(1,totals[SYMBOLIC]);
   EXPECT_EQ(5,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, symConstNotPassedinTestsRel) {

   std::string temp="{[x,y]->[x,y]:x<S}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0\nEXISTENTIAL: 0\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, symConstNotPassedinTestsRel) {

   std::string temp ="{[x,y]->[x,y]:x<S}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(4,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
   //The Relation {[x,y]->[x,y]:x<S} has 0 totals[SYMBOLIC] and
   // 0 totals[EXISTENTIAL] because the existential variable
   // S was eliminated by the ISL code in the islSimplify() method
}

#if 0
TEST(BuildSymTableVisitorTest, functionTestsNoSymconstPassedRel) {

   std::string temp="{[x,y]->[x,y]:x<f(S)}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0\nEXISTENTIAL: 0\n";
   after+= "UFCALLS    : 0\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, functionTestsNoSymconstPassedRel) {

   std::string temp ="{[x,y]->[x,y]:x<f(S)}";
   Relation PR(temp);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(4,totals[TUPLE]);
   EXPECT_EQ(1,totals[EXISTENTIAL]);
   EXPECT_EQ(1,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, functionTestsSymconstPassedRel) {

   std::string temp="{[x,y]->[x,x]:x<f(S)}";
   std::string after="SYMCONSTS  : 0 0\nTUPLEVARS  : 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    : 0\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   l1.push_back("S");
   l1.push_back("x1");
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, functionTestsSymconstPassedRel) {

   std::string temp ="{[x,y]->[x,x]:x<f(S)}";
   IEGenLibContext context;
   context.addSymbolic(Symbolic("S"));
   context.addSymbolic(Symbolic("x1"));
   Relation PR(temp, context);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(2,totals[SYMBOLIC]);
   EXPECT_EQ(4,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(1,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, functionTestsSymconstPassedUniqueNameRel) {

   std::string temp="{[x,y,x]->[x,x2,x]:x<f(S) and x4<y}";
   std::string after="SYMCONSTS  : 0 0\nTUPLEVARS  : 0 0 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    : 0\nCONST      : 0";
   PresRelation *PR = pres_parser::parse_relation(temp);
   list<string> l1;
   l1.push_back("S");
   l1.push_back("x4");
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, functionTestsSymconstPassedUniqueNameRel) {

   std::string temp ="{[x,y,x]->[x,x2,x]:x<f(S) and x4<y}";
   IEGenLibContext context;
   context.addSymbolic(Symbolic("S"));
   context.addSymbolic(Symbolic("x4"));
   Relation PR(temp, context);
   map<SymType, int> totals = PR.getTotals();

   EXPECT_EQ(2,totals[SYMBOLIC]);
   EXPECT_EQ(6,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(1,totals[UFCALL]);
}

#if 0
TEST(BuildSymTableVisitorTest, lotsOfDupX) {

   std::string temp="{[x,x,x,x,x,x,x,x]}";
   std::string after="SYMCONSTS  :\nTUPLEVARS  : 0 0 0 0 0 0 0 0\nEXISTENTIAL:\n";
   after+= "UFCALLS    :\nCONST      : 0";
   PresSet *PR = pres_parser::parse_set(temp);
   list<string> l1;
   BuildSymTableVisitor stv(l1);
   PR->apply(&stv);
   SymbolTable* mst = stv.getSymTable();

   ExpVec b = mst->constructExpVec();

   EXPECT_EQ(b.vectorStrings(),after);
   delete mst;
}
#endif

TEST(BuildSymTableVisitorTest, lotsOfDupX) {

   std::string temp ="{[x,x,x,x,x,x,x,x]}";
   Set PS(temp);
   map<SymType, int> totals = PS.getTotals();

   EXPECT_EQ(0,totals[SYMBOLIC]);
   EXPECT_EQ(8,totals[TUPLE]);
   EXPECT_EQ(0,totals[EXISTENTIAL]);
   EXPECT_EQ(0,totals[UFCALL]);
}

TEST(BuildSymTableVisitorTest, SetException) {

   std::string temp="{[x,y]:x<y}";
   PresSet *PS = iegenlib::pres_parser::parse_set(temp);
   set<string> l1;
   BuildSymTableVisitor stv(l1);
   bool flag = false;
     try{
         PS->apply(&stv);
     }
     catch(StringException err){
        flag = true;
     }

     if (!flag)
     {ADD_FAILURE()<<"BuildSymTableVisitorTest Visitor exception not raised!";}
     delete PS;
}

TEST(BuildSymTableVisitorTest, RelException) {

   std::string temp="{[x,y]->[x,z]:x<y}";
   PresSet *PR = iegenlib::pres_parser::parse_set(temp);
   set<string> l1;
   BuildSymTableVisitor stv(l1);
   bool flag = false;
   try{
        PR->apply(&stv);
   }
   catch(StringException err){
      flag = true;
   }

   if (!flag)
   {ADD_FAILURE()<<"BuildSymTableVisitorTest Visitor exception not raised!";}
   delete PR;
}
